package impl

import (
	"gitee.com/shiwjlinux/arm/apps/game"
	"gitee.com/shiwjlinux/arm/conf"
	"gitee.com/shiwjlinux/arm/ioc"
	"github.com/rs/zerolog"
	"gorm.io/gorm"
)

var (
	_ game.Service = (*Impl)(nil)
	_ ioc.Object   = (*Impl)(nil)
)

type Impl struct {
	db     *gorm.DB
	logger *zerolog.Logger
}

func init() {
	// 注册服务
	ioc.Controller.Registry(game.AppName, &Impl{})
}

func (i *Impl) Init() error {
	i.db = conf.C().MySQL.GetDB()
	// i.logger = conf.Logger.With().Str("app", game.AppName).Logger()
	// i.logger = conf.Logger().GetLogger()
	i.logger = conf.C().Log.Logger()
	i.logger.With().Str("app", game.AppName)
	return nil
}
